{% extends 'base.html' %}

{% block title %}
首页
{% endblock %}
{% block newcontent %}
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
    <div>
        <h1>所有的用户信息如下：</h1>
        搜索： <input type="text" name="search" placeholder="输入用户名或者手机号码"> <input type="button" value="搜索" id="search">
        {% if users %}
        <table>
            <tr>
                <th>序号</th>
                <th>用户名</th>
                <th>手机号码</th>
                <th>注册时间</th>
                <th>操作</th>
            </tr>
            {% for user in users %}
                <tr>
                <th>{{loop.index}}</th>
                <th>{{user.username}}</th>
                <th>{{user.phone}}</th>
                <th>{{user.rdatetime}}</th>
                <th><a href="{{ url_for('user.update') }}?id={{ user.id }}">更新</a></th>
                </tr>
            {% endfor %}
        </table>
        {% else %}
        <p style="color: red; front-size: 20px">当前没有任何用户</p>
        {% endif %}
    </div>
{% endblock %}

{% block scripts %}
    <script>
    $('#search').click(function () {
        let content = $("input[name='search']").val();
        location.href = '{{ url_for('user.search') }}?search='+content
    })
    </script>
{% endblock %}